package mt;

import java.util.*;

/**
 * @author zhangmin
 * @create 2022-03-17 20:03
 */
public class meituan2021_2_2 {

    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        if(n<2178){
            System.out.println(0);
            return;
        }
        if(n<=10000){
            System.out.println(1);
            System.out.println(2178+" "+8712);
            return;
        }
        int count=1;
        ArrayList<int[]> res=new ArrayList<>();
        res.add(new int[]{2178,8712});
        Set<Integer> set= new HashSet<>();
        set.add(2178);
        set.add(8712);
        //当i的4倍超出n时，不符合要求，所以只用遍历到n/4即可
        for (int i = 10000; i <=n/4 ; i++) {
            if (set.contains(i)) continue;
            int j=0,num=i;
            while (num>0){
                j=j*10+num%10;
                num=num/10;
            }
            if(i*4==j){
                count++;
                res.add(new int[]{i,j});
                set.add(i);
                set.add(j);
            }
        }
        System.out.println(count);
        for (int i = 0; i < count; i++) {
            System.out.println(res.get(i)[0]+" "+res.get(i)[1]);
        }
    }
}
